package com.tim.app.ui.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.application.library.runtime.event.EventManager;
import com.application.library.util.TimeUtil;
import com.tim.app.R;
import com.tim.app.constant.EventTag;
import com.tim.app.server.result.EveryDayHearListResult;

/**
 * 每日一听详情的header
 */

public class EveryDayHeadDetialHeadView extends RelativeLayout {

    public static final String TAG = "EveryDayHeadDetialHeadView";

    private TextView tvTime;
    private TextView tvPlayAll;

    public EveryDayHeadDetialHeadView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvTime = (TextView) findViewById(R.id.tvTime);
        tvPlayAll = (TextView) findViewById(R.id.tvPlayAll);
        tvPlayAll.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                EventManager.ins().sendEvent(EventTag.DO_PLAY_ALL_AND_INTO, 0, 0, null);
            }
        });
    }

    /**
     * 刷新页面
     *
     * @param data
     */
    public void setData(final EveryDayHearListResult.Res.Data data) {
        if (null == data)
            return;
//        tvTime.setText(TimeUtil.formatEverydayTime(data.getUpTime()));
        tvTime.setText(TimeUtil.formatEverydayTime(System.currentTimeMillis()));
    }

}
